package spring.security.web.config;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import spring.security.web.filter.TimeFilter;
import spring.security.web.interceptor.TimeInterceptor;

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
	
	@Autowired
	private TimeInterceptor tiemInterceptor;
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//registry.addInterceptor(tiemInterceptor);
	}
	
	@Override
	public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
		//configurer.registerCallableInterceptors(interceptors)
		//configurer.registerDeferredResultInterceptors(interceptors)
	}
	
	
	//@Bean
	public FilterRegistrationBean timeFilter() {
		FilterRegistrationBean reg = new FilterRegistrationBean();
		
		TimeFilter timeFilter = new TimeFilter();
		reg.setFilter(timeFilter);
		
		List<String> urls = new ArrayList<>();
		urls.add("/*");
		reg.setUrlPatterns(urls);
		return reg;
	}
	
}
